﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Site.Models.ProfileUser>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Details
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<div class="account_header">
    <table>
        <tr>
            <td><img src='<%= Html.DisplayFor(model => model.user.USER_AVATAR) %>' /></td>
            <td><h2>Profil de <%: Html.DisplayFor(model => model.user.UserName) %></h2></td>
            <% if (Model.clan != null) { %>
            <td><%: Html.ActionLink(Model.clan.CLAN_NAME, "Details/" + Model.clan.CLAN_ID, "Clan")%></td>
            <td><img src='<%= Html.DisplayFor(model => model.clan.CLAN_LOGOURL) %>' /></td>
            <% } %>
        </tr>
    </table>
</div>

<fieldset>
    <legend>Données personnelles : </legend>
    
    <table>
        <tr>
            <td>Pseudo</td>
            <td><%: Html.DisplayFor(model => model.user.UserName)%></td>
        </tr>
        <tr>
            <td>Date de naissance</td>
            <td>
                <%: Html.DisplayFor(model => model.birthDate)%>
            </td>
        </tr>
        <tr>
            <td>E-mail</td>
            <td><%: Html.DisplayFor(model => model.user.USER_MAIL)%></td>
        </tr>
        <tr>
            <td>Pays</td>
            <td><%: Html.DisplayFor(model => model.user.USER_COUNTRY)%></td>
        </tr>
        <tr>
            <td>Ville</td>
            <td><%: Html.DisplayFor(model => model.user.USER_CITY)%></td>
        </tr>
    </table>
</fieldset>

<p id="player_actions">
    <%
    if (Session.Contents["user_id"].ToString() == Model.user.UserId.ToString()) {     
    %>
        <%: Html.ActionLink("Editer mon profil", "Edit", new { id = Model.user.UserId })%>
        <%: Html.ActionLink("Modifier mon mot de passe", "changePassword", new { id = Model.user.UserId })%>
    <% 
    }
    else { 
    %>
        <%: Html.ActionLink("Envoyer un message", "SendMessage", "Message", new { receiver = Model.user.UserName }, new {})%>
        <% if (Model.friend == null) { %>
            <%: Html.ActionLink("Ajouter comme ami", "AddFriend", new { id = Model.user.UserId })%>
        <% } else if (Model.friend.FRIEND_ACCEPTED == 0) { %>
            <%: Html.ActionLink("Accepter la demande d'amitié", "AcceptFriend", new { id = Model.user.UserId })%>
        <% } else if (Model.friend.FRIEND_ACCEPTED == 2) {%>
            <%: Html.ActionLink("Retirer de la liste d'amis", "DeleteFriend", new { id = Model.user.UserId })%>
        <% } %>
    <% } %>
</p>

<fieldset>
    <legend>Statistiques personnelles : </legend>
    
    <% foreach (var stat in Model.stats) { %>
        <%  var type = "";
            switch (stat.STAT_GAMETYPE) {
               case 11 :
                    type = "1v1";
                    break;
               case 1111 :
                    type = "1v1v1v1";
                    break;
               case 221 :
                    type = "2v2 fixe";
                    break;
               case 222:
                    type = "2v2 aléatoire";
                    break;
        } %>
        <table>
            <caption>Parties <%: type %></caption>
            <tr>
                <td>Classement </td>
                <td><%: stat.STAT_RANK %></td>
            </tr>
            <tr>
                <td>Total de parties gagnées</td>
                <td><%: stat.STAT_WONGAMES %></td>
            </tr>
            <tr>
                <td>Total de parties perdues</td>
                <td><%: stat.STAT_LOSTGAMES %></td>
            </tr>
            <tr>
                <td>Total de parties abandonnées</td>
                <td><%: stat.STAT_ABANDONEDGAMES %></td>
            </tr>
        </table>
    <% } %>
    
</fieldset>

<% if (Session.Contents["user_id"].ToString() == Model.user.UserId.ToString()) { %>
<p>
    <%: Html.ActionLink("Se désinscrire", "Unsuscribe")%>
</p>
<% } %>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="alerts" runat="server">
</asp:Content>
